package com.adam.masterSpringMVC4.controller.api;

import com.adam.masterSpringMVC4.weibo.WeiboData;
import com.adam.masterSpringMVC4.weibo.WeiboService;
import com.fasterxml.jackson.annotation.JsonView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.MatrixVariable;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/search")
public class SearchApiController {

    private WeiboService weiboService;

    @Autowired
    public SearchApiController(WeiboService weiboService) {
        this.weiboService = weiboService;
    }

    @RequestMapping("/{searchType}")
    @JsonView(WeiboData.DetailView.class)
    public List<WeiboData> search(@PathVariable("searchType")String searchType, @MatrixVariable List<String> keywords) {
        return weiboService.search(searchType, keywords);
    }

}
